package com.mtr.databoard.domain.components;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class ComponentStore {

    private IComponentRepository componentRepository;

    public ComponentStore(@Autowired IComponentRepository componentRepository) {
        this.componentRepository = componentRepository;
    }

    /**
     * 根据id获取组件
     * @param componentId
     * @return
     */
    public ViewComponent getViewComponetById(UUID componentId)
    {
        if(componentRepository.existsById(componentId))
            return  componentRepository.findById(componentId).get();
        return  null;
    }
}
